package ldkxingzhe.ldkxingzhedemo.touchevent;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.widget.LinearLayout;
import android.widget.TextView;

import ldkxingzhe.ldkxingzhedemo.utils.LogDemo;

/**
 * Created by liangdengke on 2015/9/6.
 */
public class ScaleDetectGestureActivity extends AppCompatActivity implements ScaleGestureDetector.OnScaleGestureListener {

    private final String TAG = ScaleDetectGestureActivity.class.getSimpleName();

    ScaleGestureDetector scaleGestureDetector;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        LinearLayout layout = new LinearLayout(this);
        TextView textView = new TextView(this);
        textView.setText("test For ScaleDetectGesture");
        layout.addView(textView);
        setContentView(layout);

         scaleGestureDetector = new ScaleGestureDetector(this,this);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        scaleGestureDetector.onTouchEvent(event);
        return super.onTouchEvent(event);
    }

    @Override
    public boolean onScale(ScaleGestureDetector detector) {
        LogDemo.i(TAG,"onScale");
        return false;
    }

    @Override
    public boolean onScaleBegin(ScaleGestureDetector detector) {
        LogDemo.i(TAG,"onScaleBegin");
        // From here, you should know why onDown in GestureDetector need return true if you want to capture other gesture.
        return true;
    }

    @Override
    public void onScaleEnd(ScaleGestureDetector detector) {
        LogDemo.i(TAG,"onScaleEnd");
    }
}
